//
//  Screen.swift
//  SwiftuiZsa
//
//  Created by hccc on 2023/7/24.
//

import Foundation
import SwiftUI
import UIKit

enum Screen {
    static let width = UIScreen.main.bounds.width
    static let height = UIScreen.main.bounds.height
    static let bounds = MakeRect(0, 0, width, height)

    static let statusBarHeight: CGFloat = {
        if #available(iOS 13.0, *) {
            let statusBarManager = UIApplication.shared.windows.first?.windowScene?.statusBarManager
            return statusBarManager?.statusBarFrame.height ?? 0
        } else {
            return UIApplication.shared.statusBarFrame.height
        }
    }()

    static let navbarHeight: CGFloat = 44 + statusBarHeight

    static let mainTabHeight: CGFloat = 49

    static let safeAreaInsets: UIEdgeInsets = {
        let window = UIApplication.shared.connectedScenes
            .compactMap {
                $0 as? UIWindowScene
            }
            .flatMap {
                $0.windows
            }
            .first {
                $0.isKeyWindow
            }
        return window?.safeAreaInsets ?? UIEdgeInsets()
    }()
}
